<?php

class Df extends Controller {

	// Constructor
	function Df()
    {
       
		parent::Controller();
		
		// load model
		$this->load->model('Df602_model', 'df602', TRUE);
		
		// select table to scaff
		$this->load->scaffolding('realtime');
		
		// load session lib
		$this->load->library('session');
		
		$this->load->helper('form');
	}
	
	function cron()
	{
		
		$hostlist = $this->df602->get_all_client_info() ;
		//$this->df602->truncateRealtime();
		$params = array('clientid' => 1, 'clientname' => 2);
		$this->load->library('DFData', $params);
		foreach($hostlist as $host)
		{
			$params = array('clientid' => $host->id, 'clientname' => $host->username);
			//if(isset($this->dfdata)) unset($this->dfdata);
			//$this->load->library('DFData', $params);
			echo $this->dfdata->clientname;
			
			
			/* $dfcommand = "df -k | grep /dev/[s,h]d." ; //default
			if ( isset($host->dfcommand))
				if ($host->dfcommand != "")
					$dfcommand = $host->dfcommand ;
			
			if(isset($this->sshsesssion)) unset($this->sshsesssion);
			$this->load->library('SSHSession');
			
			$params = array('clientid' => $host->id, 'clientname' => $host->username);
			if(isset($this->dfdata)) unset($this->dfdata);
			$this->load->library('DFData', $params);
			echo $this->dfdata->clientname;
			
			$this->sshsession->connect($host->hostname, $host->username, $host->password);
			if(!$this->sshsession->ok) {
				echo "<bWarning</b>host :".$host->hostname." error" ;
				//makeErrorQuery;
				//skiping to next host
			}
			else
			{
				$this->sshsession->exec($dfcommand);
				while(!$this->sshsession->EOF())
				{
					$dfline = $this->sshsession->readln();
					$this->dfdata->decodeDF($dfline) ;
				}
				//Insert to History Table
				$historyInsertQuery = $this->dfdata->makeInsertQuery();
				//$mysql->execute($historyInsertQuery);
				//Insert to RealTime Table
				$realTimeInsertQuery = ereg_replace("history","realtime",$historyInsertQuery);
				//$mysql->execute($realTimeInsertQuery);
				$this->dfdata->show();
			} */
		} 
	}
}











?>